home *** CD-ROM | disk | FTP | other *** search
/ Ham Radio 2000 / Ham Radio 2000.iso / ham2000 / packet / terminal / top_152 / src152.exe / rar / TOPDOS.PAS < prev    next >
Pascal/Delphi Source File  |  1995-05-16  |  6KB  |  219 lines

  1. {┌─────────────────────────────────────────────────────────────────────────┐}
  2. {│                                                                         │}
  3. {│                              T. O. P.                                   │}
  4. {│                                                                         │}
  5. {│                        (T)he  (O)ther  (P)acket                         │}
  6. {│                                                                         │}
  7. {│ T O P D O S . P A S                                                     │}
  8. {│                                                                         │}
  9. {│                                                                         │}
  10. {│ Routinen für den DOS-Austieg                                            │}
  11. {└─────────────────────────────────────────────────────────────────────────┘}
  12.  
  13.  
  14. Procedure DosAufruf (* Var Zeile : Str128; Art : Byte *);
  15. Var    Flag : Boolean;
  16.        f    : File;
  17.        INr,
  18.        i,Z  : Byte;
  19.  
  20. Begin
  21.   Ini_TNC_Text(1);
  22.   if Art = 1 then Teil_Bild_Loesch(1,maxZ,7);
  23.   if Art = 2 then Teil_Bild_Loesch(1,maxZ,Attrib[18]);
  24.  
  25.   SetzeCursor(1,2);
  26.  
  27.   Flag := (Zeile = '');
  28.   if Flag then WriteRam(1,1,Attrib[5],0,InfoZeile(254));
  29.  
  30.   if Zeile > '' then Zeile := COM_C + Zeile;
  31.  
  32.   Close_SaveFiles;
  33.   StoreHeap;
  34.  
  35.   Call_DOS(Zeile);
  36.  
  37.   LoadHeap;
  38.   if DosError = 0 then Zeile := 'OK' else Zeile := '';
  39.   Open_SaveFiles;
  40.  
  41.   Z := Zeilen_ermitteln;
  42.  
  43.   if (Art = 1) and not Flag then
  44.   begin
  45.     Teil_Bild_Loesch(Z,Z,7);
  46.     WriteRam(1,Z,Attrib[5],0,InfoZeile(78));
  47.     SetzeCursor(length(InfoZeile(78))+2,Z);
  48.     Warten;
  49.   end;
  50.  
  51.   if Art = 2 then
  52.   begin
  53.     Assign(f,G^.TempPfad + DosBild);
  54.     if ResetBin(f,T) = 0 then
  55.     begin
  56.       if FileSize(f) = 0 then
  57.       begin
  58.         FiResult := CloseBin(f);
  59.         FiResult := EraseBin(f);
  60.         DosBildSave(Z);
  61.       end else FiResult := CloseBin(f);
  62.     end else DosBildSave(Z);
  63.   end;
  64.  
  65.   if Z <> maxZ then Switch_VGA_Mono;
  66.   ColorItensity(HighCol);
  67.   Cursor_Aus;
  68.  
  69.   if not HwHs and HardCur then for i := 1 to 4 do
  70.    with COM[i] do if Active then
  71.    begin
  72.      Port[Base + $01] := $01;
  73.    end;
  74.  
  75.   Ini_TNC_Text(0);
  76.   Neu_Bild;
  77.   Init_HardDrive;
  78. End;
  79.  
  80. Procedure ExecDOS (* Zeile : str128 *);
  81. Var   Z : Byte;
  82. Begin
  83.   if Zeile > '' then Zeile := COM_C + Zeile;
  84.  
  85.   Ini_TNC_Text(1);
  86.   Teil_Bild_Loesch(1,maxZ,7);
  87.   SetzeCursor(1,1);
  88.   Close_SaveFiles;
  89.   StoreHeap;
  90.  
  91.   Call_DOS(Zeile);
  92.  
  93.   LoadHeap;
  94.   Open_SaveFiles;
  95.  
  96.   Z := Zeilen_ermitteln;
  97.   if Z <> maxZ then Switch_VGA_Mono;
  98.   ColorItensity(HighCol);
  99.   Cursor_aus;
  100.   Init_HardDrive;
  101.   Ini_TNC_Text(0);
  102. End;
  103.  
  104. Procedure DosBildSave (* Zeilen : Byte *);
  105. var i,i1,
  106.     max  : Word;
  107.     f    : text;
  108.     H    : string[80];
  109.  
  110. Begin
  111.   H := '';
  112.   Assign(f,G^.TempPfad + DosBild);
  113.   FiResult := RewriteTxt(f);
  114.   i1 := 1;
  115.   max := Zeilen * 160;
  116.   for i := 1 to max do
  117.   begin
  118.     if i mod 2 = 1 then
  119.     begin
  120.       if Bild^[i] in [#32..#254] then H := H + Bild^[i];
  121.       inc(i1);
  122.       if i1 > 80 then
  123.       begin
  124.         KillEndBlanks(H);
  125.         if H <> '' then Writeln(f,H);
  126.         H := '';
  127.         i1 := 1;
  128.       end;
  129.     end; 
  130.   end;
  131.   Writeln(f);
  132.   FiResult := CloseTxt(f);
  133. End;
  134.  
  135. Procedure StoreHeap;
  136. var       Result : Word;
  137.           Zaehl  : LongInt;
  138. Begin
  139.   HeapFeld := HeapOrg;
  140.   Zaehl := Adr_absolut(HeapPtr) - Adr_absolut(HeapOrg);
  141.   SizeHeap := Zaehl;
  142.   if use_XMS and ((LongInt(get_XMS_Free) * 1024) > Zaehl) then
  143.   begin
  144.     SwpHandle := get_XMS_Ram((Zaehl div 1024) + 2);
  145.     Data_to_XMS(HeapOrg,SwpHandle,0,SizeHeap);
  146.     SwapXms := true;
  147.   end else
  148.   begin
  149.     if Vdisk_Exists and (DiskFree(ord(VDisk[1])-64) > (Zaehl + 2048))
  150.        then  Assign(HeapFile,VDisk + SwapDatei)
  151.        else  Assign(HeapFile,G^.TempPfad + SwapDatei);
  152.     FiResult := RewriteBin(HeapFile,T);
  153.     if Zaehl > $FFFF then
  154.     Repeat
  155.       if Zaehl >= $FFFF  then BlockWrite(HeapFile,HeapFeld^,$FFFF,Result)
  156.                          else BlockWrite(HeapFile,HeapFeld^,Word(Zaehl),Result);
  157.       Zaehl := Zaehl - Result;
  158.       HeapFeld := Ptr(Seg(HeapFeld^) + $1000,Ofs(HeapFeld^));
  159.     Until Zaehl <= 0 else BlockWrite(HeapFile,HeapFeld^,Zaehl,Result);
  160.     FiResult := CloseBin(HeapFile);
  161.   end;
  162. End;
  163.  
  164. Procedure LoadHeap;
  165. var       Result : Word;
  166. Begin
  167.   HeapFeld := HeapOrg;
  168.   if use_XMS and SwapXms then
  169.   begin
  170.     XMS_to_Data(HeapOrg,SwpHandle,0,SizeHeap);
  171.     SwapXMS := false;
  172.     Free_XMS_Ram(SwpHandle);
  173.   end else
  174.   begin
  175.     FiResult := ResetBin(HeapFile,T);
  176.     Repeat
  177.       BlockRead(HeapFile,HeapFeld^,$FFFF,Result);
  178.       HeapFeld := Ptr(Seg(HeapFeld^) + $1000,Ofs(HeapFeld^));
  179.     Until Result <= 0;
  180.     FiResult := CloseBin(HeapFile);
  181.     FiResult := EraseBin(HeapFile);
  182.   end;
  183. End;
  184.  
  185.  
  186. Function  Zeilen_ermitteln (* : Byte *);
  187. var    r : Registers;
  188.        i : Integer;
  189. Begin
  190.   if Hercules then Zeilen_ermitteln := 25 else
  191.   begin
  192.     r.ah := $11;
  193.     r.al := $30;
  194.     intr($10,r);
  195.     i := Byte(r.dl + 1);
  196.     if i in [25,30,34,43,50,60] then Zeilen_ermitteln := Byte(i)
  197.                                 else Zeilen_ermitteln := 25;
  198.   end;
  199. End;
  200.  
  201. Procedure Switch_VGA_Mono;
  202. Begin
  203.   if not Hercules then
  204.   begin
  205.     if _VGA then TextMode(LastModeStore or $100)
  206.             else TextMode(LastModeStore and $FF);
  207.   end;
  208. End;
  209.  
  210. Procedure Ini_TNC_Text (* Art : Byte *);
  211. Var  i : Byte;
  212. Begin
  213.   for i := 1 to TNC_Anzahl do
  214.   begin
  215.     K[0]^.TncNummer := i;
  216.     S_PAC(0,CM,true,'U' + int_str(Art));
  217.   end;
  218. End;
  219.